package com.swl.controller;

import com.swl.pojo.Course;
import com.swl.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/course")
public class CourseController {
    @Autowired
    private CourseService courseService;
    @ResponseBody
    @RequestMapping("/insertCourse")
    public Integer addCourse(Course course){
        System.out.println(course);
        int i=courseService.insertCourse(course);
        return i;
    }

    @RequestMapping("/selectAllBySchoolId")
    @ResponseBody
    public List<Course> selectCourseBySchoolId(@RequestParam("schoolId") int schoolId){
        System.out.println("选中的学校编号为："+schoolId);
        return courseService.selectCourseBySchoolId(schoolId);
    }

    @RequestMapping("/selectAll")
    @ResponseBody
    public List<Course> selectAll(){
        System.out.println("selectAll执行了");
        return courseService.selectAll();
    }

}
